﻿using System;
using System.Configuration;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.DBM;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IDAL;

namespace KPIS.GERP.GFMS.DAL
{
    public class D_FIM_MAS_Events : IDAL_FIM_MAS_Events
    {
        DBManager dbManager = new DBManager(SystemInfo._DataProvider, ConfigurationSettings.AppSettings["ConnectionString"].ToString());
        //

        public D_FIM_MAS_Events()
        {

        }

        public IList<M_FIM_MAS_Events> GetList()
        {
            string strSQL;
            DataRowCollection drc = null;
            IList<M_FIM_MAS_Events> infoList = new List<M_FIM_MAS_Events>();
            try
            {
                dbManager.Open();
                dbManager.CreateParameters(1);

                dbManager.AddParameters(0, "@delete_status", SystemInfo._DeleteRecordStatus);

                strSQL = "SELECT event_seq, event_name"
                    + " FROM fim_mas_events"
                    + " WHERE record_status not like 'D'"
                    + " ORDER BY event_seq";

                drc = dbManager.ExecuteDataSet(CommandType.Text, strSQL).Tables[0].Rows;
                if (drc.Count > 0)
                {
                    for (int i = 0; i < drc.Count; i++)
                    {
                        M_FIM_MAS_Events info = new M_FIM_MAS_Events();
                        info.event_seq = Convert.ToInt32(drc[i]["event_seq"]);
                        info.event_name = drc[i]["event_name"].ToString();
                        infoList.Add(info);
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                dbManager.Dispose();
            }

            return infoList;
        }
    }
}